package com.lu.bootexception.controller;

import com.lu.bootexception.exception.ErrorReturnPageException;
import com.lu.bootexception.exception.ErrorReturnResultException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ExceptionController {

    @RequestMapping("testReturnResult")
    public String testReturnResult(){
        throw new ErrorReturnResultException("测试全局异常捕获响应json数据");
    }

    @RequestMapping("testReturnPage")
    public String testReturnPage(){
        throw new ErrorReturnPageException("测试全局异常捕获跳转错误页面");
    }


    @RequestMapping("test500")
    public String test500(){
        int i = 50/0;
        return "正常访问";
    }

    /**
     * 修改默认配置 出现500的时候访问这个方法
     * @return
     */
    @RequestMapping("testData")
    @ResponseBody
    public String testData(){
        return "后台错误 请联系管理员";
    }
}
